package doublepointer;

/**
 * @Classname : SumOfSquareNumbers
 * @Description : <a href="https://leetcode.cn/problems/sum-of-square-numbers/">633. 平方数之和</a>
 * @Author : chentianyu
 * @Date 2023/2/23 23:49
 */


public class SumOfSquareNumbers {
    public boolean judgeSquareSum(int c) {
        long a = 0, b = (long) Math.sqrt(c);
        while (a <= b) {
            long sum = a*a + b*b;
            if (sum == c) return true;
            else if (sum < c) a++;
            else b--;
        }
        return false;
    }
}
